<?php
use Imi\Server\Type;

// 注释项代表可省略的，使用默认值
return [
    // 项目根命名空间
    'namespace'    =>    'ImiDemo\TcpDemo',
    // 扫描目录
    'beanScan'    =>    [
    ],
    // 主服务器配置，提供websocket服务
    'mainServer'    =>    [
        'namespace'    =>    'ImiDemo\TcpDemo\MainServer',
        'type'        =>    Type::TCP_SERVER,
        // 'host'        =>    '0.0.0.0',
        'port'        =>    8085,
        // 'mode'        =>    SWOOLE_BASE,
        // 'sockType'    =>    SWOOLE_SOCK_TCP,
        'configs'    =>    [
            'reactor_num'        =>    2,
            'worker_num'        =>    2,
            'task_worker_num'    =>    8,
            // EOF自动分包
            'open_eof_split'    =>    true, //打开EOF_SPLIT检测
            'package_eof'        =>    "\r\n", //设置EOF
        ],
        // 数据处理器
        'dataParser'    =>    \ImiDemo\TcpDemo\MainServer\Parser\JsonObjectParser::class,
    ],
    // 子服务器（端口监听）配置
    'subServers'        =>    [
        // 子服务器名
        'tcp2'    =>    [
            'namespace'    =>    'ImiDemo\TcpDemo\Tcp2',
            'type'        =>    Type::TCP_SERVER,
            // 'host'        =>    '0.0.0.0',
            'port'        =>    8086,
            // 'mode'        =>    SWOOLE_PROCESS,
            // 'sockType'    =>    SWOOLE_SOCK_TCP,
            'configs'    =>    [
                // 固定包头
                'open_eof_split'        => false,
                'open_length_check'     => true,
                'package_length_type'   => 'N',
                'package_length_offset' => 0,       //第N个字节是包长度的值
                'package_body_offset'   => 4,       //第几个字节开始计算长度
                'package_max_length'    => 1024 * 1024,  //协议最大长度
            ],
            'dataParser'    =>    \ImiDemo\TcpDemo\Tcp2\Parser\JsonObjectParser::class,
        ],
    ],
    // 配置文件
    'configs'    =>    [
        'beans'        =>    __DIR__ . '/beans.php',
    ],
    'pools'    =>    [
        'redis'    =>    [
            'sync'    =>    [
                'pool'    =>    [
                    'class'        =>    \Imi\Redis\SyncRedisPool::class,
                    'config'    =>    [
                        'maxResources'    =>    5,
                        'minResources'    =>    1,
                    ],
                ],
                'resource'    =>    [
                    'host'    =>    '127.0.0.1',
                    'post'    =>    6379,
                    // 密码
                    // 'password'    =>    '',
                    // 第几个库
                    // 'db'    =>    0,
                ]
            ],
            'async'    =>    [
                'pool'    =>    [
                    'class'        =>    \Imi\Redis\CoroutineRedisPool::class,
                    'config'    =>    [
                        'maxResources'    =>    5,
                        'minResources'    =>    1,
                    ],
                ],
                'resource'    =>    [
                    'host'    =>    '127.0.0.1',
                    'post'    =>    6379,
                    // 密码
                    // 'password'    =>    '',
                    // 第几个库
                    // 'db'    =>    0,
                ]
            ],
        ],
    ],
    'caches'    =>    [
        // 文件缓存
        'f1'    =>    [
            'handlerClass'    =>    \Imi\Cache\Handler\File::class,
            'option'        =>    [
                'savePath'    =>    dirname(__DIR__, 3) . '/cache',
            ],
        ],
        // redis缓存
        'r1'    =>    [
            'handlerClass'    =>    \Imi\Cache\Handler\Redis::class,
            'option'        =>    [
                'poolName'    =>    'redis',
            ],
        ],
    ],
];